package org.easy.platform.system.factory;

import lombok.extern.slf4j.Slf4j;
import org.easy.common.utils.StringUtils;
import org.easy.platform.system.feign.SystemApiFeign;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import static org.easy.platform.system.constant.SystemServiceNameConstants.*;

/**
 * 类说明
 *
 * @author YanMing
 * @date 2024/4/29
 */
@Slf4j
@Component
public class RemoteSystemFallbackFactory implements FallbackFactory<SystemApiFeign>{

    @Override
    public SystemApiFeign create(Throwable cause) {
        log.error("{}调用失败:{}",SYSTEM_NAME, cause.getMessage());
        return new SystemApiFeign(){
            @Override
            public String hello(String content ) {
                return StringUtils.format("调用失败{} --> hello({})。", SYSTEM_NAME, content);
            }
        };
    }
}
